package org.example.Server.controller.examination;

import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.examination.ExamStu;
import org.example.Server.model.examination.ExamStuQs;
import org.example.Server.model.examination.ExamStuQsDTO;
import org.example.Server.service.examination.TeachExamService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/youxich/exam/teacher/paper/anslist")
public class TeachExamAnslistController {
    @Autowired
    private TeachExamService teachExamService;

    /**
     * 获取试卷答题列表
     *
     * @param division_id   分班id
     * @param submit_status 提交状态0未提交1已提交
     * @param mark_status   批阅状态0未评阅1已评阅
     * @param exam_id       试卷id
     * @return
     */
    @GetMapping()
    public ResultAPI getPaperAnsList(@RequestParam(required = false) Integer division_id,
                                     @RequestParam(required = false) Integer submit_status,
                                     @RequestParam(required = false) Integer mark_status,
                                     @RequestParam Integer exam_id) {
        ResultAPI result = null;
        result = teachExamService.getPaperAnsList(division_id, submit_status, mark_status, exam_id);
        return result;
    }

    /**
     * 获取学生答题详情：模块得分，每一题得分等
     *
     * @param examStu
     * @return
     */
    @PostMapping("/detail")
    public ResultAPI getExamDetail(@RequestBody ExamStu examStu) {
        ResultAPI result = null;
        result = teachExamService.getExamStuDetail(examStu);
        return result;
    }

    /**
     * 评阅学生成绩
     *
     * @param examStuQsDTO
     * @return
     */
    @PatchMapping
    public ResultAPI updateExamStu(@RequestBody ExamStuQsDTO examStuQsDTO) {
        ResultAPI result = null;
        result = teachExamService.updateExamStu(examStuQsDTO);
        return result;
    }
}
